package ru.niir.goodfil.excel.impl;

import ru.niir.goodfil.audit.util.Assert;
import ru.niir.goodfil.excel.client.CellRenderer;
import ru.niir.goodfil.excel.client.ColumnModel;
import ru.niir.goodfil.excel.client.HeaderModel;
import ru.niir.goodfil.excel.client.ValueExtractor;

/**
 * @author: Кирилл
 */
public class DefaultColumnModel implements ColumnModel {
    private final String propertyName;

    private HeaderModel headerModel;

    private CellRenderer renderer = new DefaultTextCellRenderer();

    private ValueExtractor extractor;

    private Integer width;

    public DefaultColumnModel(String propertyName) {
        Assert.notBlank(propertyName);

        this.propertyName = propertyName;
        this.headerModel = new DefaultHeaderModel(propertyName);
        this.extractor = new DefaultValueExtractor(propertyName);
    }

    public String getPropertyName() {
        return propertyName;
    }

    public CellRenderer getRenderer() {
        return renderer;
    }

    public HeaderModel getHeaderModel() {
        return headerModel;
    }

    public ValueExtractor getValueExtractor() {
        return extractor;
    }

    public void setExtractor(ValueExtractor extractor) {
        this.extractor = extractor;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public void setRenderer(CellRenderer renderer) {
        this.renderer = renderer;
    }

    public void setHeaderModel(HeaderModel headerModel) {
        this.headerModel = headerModel;
    }
}
